<html>
<meta name=”viewport” content=”width=device-width, initial-scale=1″ />
<head>
    <meta charset="utf-8">
    <title>信用分申诉</title>
    <script src="../commonCss.js"></script>
    <script src="../commonJs.js"></script>
    <link rel="stylesheet" href="../../css/common.css">
</head>

<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <div class="ctc_title">信用分申诉</div>
    <div class="down_line"></div>
</section>

<!-- Main content -->
<section class="content" >
    <div class="row">
        <div class="col-xs-12">
            <div class="box-header">
                <form class="form-inline">
                    <div class="form-group">
                        <label>查询：</label>
                        <div class="form-group">
                            <select class="form-control" id="flag">
                                <option value="">全部</option>
                                <option value="-1">未申诉</option>
                                <option value="0">待处理</option>
                                <option value="1">申诉成功</option>
                                <option value="2">申诉失败</option>
                            </select>
                        </div>
                        <input style="width: 260px;" class="form-control" type="text" id="searchKey"  placeholder="输入手机号/用户姓名搜索"/>
                    </div>
                    <div class="form-group">
                        <button type="button"  onclick="getData()"  class="btn btn-block btn-primary">搜索</button>
                    </div>

                </form>
            </div>

            <div class="box-body" style="height:100%;">
                <table id="dataList" class="table table-bordered table-hover" >
                    <thead>
                    <tr>
                        <th>用户手机号</th>
                        <th>用户姓名</th>
                        <th>众筹单标题</th>
                        <th>信用分</th>
                        <th>原因</th>
                        <th>状态</th>
                        <th>创建时间</th>
                        <th>申诉处理</th>
                    </tr>
                    </thead>
                    <tbody >
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</section>

<!-- 【信用扣分申诉处理】弹出窗内容 -->
<div class="modal" id="punishDialog" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">×</span>
                    <span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title" align="center" >信用扣分申诉处理</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" onsubmit="return false">
                    <fieldset  style="margin-top: 1%;">
                        <div class="form-group">
                            <input type="hidden" id="appealId"/>
                            <label class="col-md-2 control-label">银行卡号：</label>
                            <div class="col-md-10">
                                <span id="cardNum" class="form-control" style="border: 0px;font-size: 17px;"/>
                            </div>
                            <label class="col-md-2 control-label">账单金额：</label>
                            <div class="col-md-10">
                              <span id="billMoney" class="form-control" style="border: 0px;font-size: 17px;"/>
                            </div>
                            <label class="col-md-2 control-label" >账单截图：</label>
                            <div class="col-md-10">
                                <img id="img" style="border:1px dashed #ddd;width:150px;" onclick="maxPic(this.src)">
                                <img id="img2" style="border:1px dashed #ddd;width:150px;" onclick="maxPic(this.src)">
                                <img id="img3" style="border:1px dashed #ddd;width:150px;" onclick="maxPic(this.src)">
                            </div>
                        </div>
                    </fieldset>
                </form>
            </div>
            <div class="modal-footer" style="text-align: center" id="but_div">
                <button type="button" class="btn btn-primary" onclick="pass();">申诉成功</button>
                <button type="button" class="btn btn-default" onclick="notPass()" >申诉失败</button>
            </div>
        </div>
    </div>
</div>

<!-- 【图片点击放大】弹出窗内容 -->
<div class="modal" id="picMonthDialog" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" align="center">账单</h4>
            </div>
            <img id="maxPic" width="100%">
        </div>
    </div>
</div>

<!-- page script -->
<script>
    $(document).ready(function() {
        layui.use('layer', function(){
            var layer = layui.layer;
        });
        //加载数据
        getData();
    });
    // 加载数据
    function getData(){
        var table = $('#dataList').DataTable({
            "destroy": true,   //可以重新初始化，用于搜索
            "lengthChange": false,
            "ordering": false,   //排序
            "info": true,		   //
            "autoWidth": false,   //宽度自动
            "paging": true,      //分页
            "searching": false,  //全局搜索关闭
            "processing": true,  //开启显示‘正在加载.../processing’
            "serverSide":true,    //true代表后台处理分页，false代表前台处理分页
            "ajax" :  {
                url:"/creditPoint/getAppealList",
                type:"post",
                data:{
                    key : $("#searchKey").val(),
                    flag: $("#flag").val()
                },
                dataSrc: function (myJson) {
                    return myJson.data.data;
                }
            },
            //参数显示
            "columns": [
                {"data": "mobile", 'sClass': "text-center",'width': '6%'},
                {"data": "partyName", 'sClass': "text-center",'width': '5%'},
                {"data": "title", 'sClass': "text-center",'width': '10%'},
                {"data": "creditPoint", 'sClass': "text-center",'width': '3%'},
                {"data": "reason", 'sClass': "text-center",'width': '12%'},
                {"data": "status", 'sClass': "text-center","width":'3%',
                    "render":function(data,type,full,meta){
                        var str="";
                        if(data == -1){
                            str="<span class='label label-default' style='background-color:gray;padding-left:10px;padding-right:10px;padding-top: inherit;'>未申诉</span>";
                        }else if(data == 0){
                            str="<span class='label label-warning' style='padding-left:10px;padding-right:10px;padding-top: inherit;'>待处理</span>";
                        }else if(data == 1){
                            str += "<span class='label label-success' style='padding-left:10px;padding-right:10px;padding-top: inherit;' >申诉成功</span> ";
                        }else if(data == 2){
                            str += "<span class='label label-danger' style='padding-left:10px;padding-right:10px;padding-top: inherit;'>申诉失败</span>";
                        }
                        return str;
                    }
                },
                {"data": "createTime", 'sClass': "text-center",'width': '6%',
                    "render":function( data, type, full, meta) {
                        return toDate(data).format('yyyy-MM-dd HH:mm:ss');
                    }
                },
                {"data":"img" , 'sClass': "text-center" ,'width':'3%',
                    "render": function (data, type, full, meta ) {
                        var str ="";
                    if(full.status != -1){
                        str = "<a href = '#' title='申诉处理' onclick=editData('" + data +"',"+full.billMoney+","+full.appealId+","+"'"+full.cardNum+"'"+","+full.status+");><i class='\glyphicon glyphicon-eye-open'></i></a>&nbsp;&nbsp;&nbsp;";
                    }
                        return str;
                    }
                }
            ],

            //是否开启主题
            "bJQueryUI": true,
            "oLanguage": {    // 语言设置
                "sLengthMenu": "每页显示 _MENU_ 条记录",
                "sZeroRecords": "抱歉， 没有找到",
                "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                "sInfoEmpty": "没有数据",
                "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                "sZeroRecords": "没有检索到数据",
                "sSearch": "检索:",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "前一页",
                    "sNext": "后一页",
                    "sLast": "尾页"
                }
            }
        });
    }

    //申诉处理
    function editData(img,billMoney,appealId,cardNum,status) {
        $("#appealId").val(appealId);
        $("#billMoney").text(billMoney);
        $("#cardNum").text(cardNum);
        //清除之前的图片缓存
        $("#img").attr("src","");
        $("#img2").attr("src","");
        $("#img3").attr("src","");

        $("#img").attr("src",img.split("$")[0]);
        if(img.split("$").length > 1){
            $("#img2").attr("src",img.split("$")[1]);
            $("#img2").show();
        }else{
            $("#img2").hide();
        }
        if(img.split("$").length > 2){
            $("#img3").attr("src",img.split("$")[2]);
            $("#img3").show();
        }else{
            $("#img3").hide();
        }
        //控制审批按钮
        if(status == 0){
            $("#but_div").show();
        }else{
            $("#but_div").hide();
        }
        $("#punishDialog").modal("show");
    }

    //申诉通过
    function pass(){
        var appealId = $("#appealId").val();
       if(confirm("请再次确认账号信息是否真实，审核通过后用户诚信值将恢复！")){
           $.ajax({
               url:"/creditPoint/appeal",
               type:"POST",
               async : true,//默认就是true
               dataType:"json",
               data:{
                   appealId : appealId ,
                   flag : 1   //1：通过,2：未通过，
               },
               success:function(data) {
                   layer.msg(data.message);
                   $("#punishDialog").modal("hide");
                   getData();
               }
           });
       }
    }

    //申诉不通过
    function notPass() {
        var appealId = $("#appealId").val();
        if(confirm("请再次确认账号信息是否真实，审核后不能修改！")){
            $.ajax({
                url:"/creditPoint/appeal",
                type:"POST",
                async : true,//默认就是true
                dataType:"json",
                data:{
                    appealId : appealId ,
                    flag : 2   //1：通过,2：未通过，
                },
                success:function(data) {
                    layer.msg(data.message);
                    $("#punishDialog").modal("hide");
                    getData();
                }
            });
        }

    }

</script>
</body>
</html>
